import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../utils/bt_app_bar_utils.dart';
import '../models/bt_file_preview_model.dart';

@RoutePage(name: "filePreviewRoute")
class BtFilePreviewScreen extends StatelessWidget {
  const BtFilePreviewScreen({super.key, required this.name, required this.url});

  final String name;

  final String url;

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (context) => BtFilePreviewModel(name, url),
      child: Consumer<BtFilePreviewModel>(builder: (context, model, _) {
        return Scaffold(
          backgroundColor: const Color(0xFFFFFFFF),
          appBar: appBar(context, '', null),
          body: Container(
            width: MediaQuery.of(context).size.width,
            color: const Color(0xFFF7F8FA),
            padding: const EdgeInsets.only(top: 186),
            child: Column(
              children: [
                Image.asset(
                  'assets/images/bt_icon_file_preview.png',
                  width: 104,
                  height: 104,
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 10),
                  child: Text(name, style: const TextStyle(fontSize: 14, color: Color(0x4d000000))),
                ),
                const SizedBox(height: 300),
                InkWell(
                  child: Container(
                      width: MediaQuery.of(context).size.width - 114,
                      height: 52,
                      decoration: BoxDecoration(
                        color: const Color(0xFF4DB4FF),
                        borderRadius: BorderRadius.circular(46),
                      ),
                      child: const Padding(
                        padding: EdgeInsets.only(top: 12),
                        child: Text("Open",
                            textAlign: TextAlign.center,
                            style: TextStyle(
                                fontSize: 18, color: Color(0xFFFFFFFF), fontWeight: FontWeight.bold)),
                      )),
                  onTap: () {
                    model.openFile();
                  },
                ),
              ],
            ),
          ),
        );
      }),
    );
  }
}
